#ifndef _NE_VERTEX_ATTRIBUTE_H_
#define _NE_VERTEX_ATTRIBUTE_H_

#include <common/SharedPtr.h>
#include <graphics/RenderSystemDefine.h>

namespace ne
{
    struct VertexAttributeInfo
    {
        uint32_t mSemantic;
        uint32_t mType;
        uint32_t mCount;
        uint32_t mStride;
        uint32_t mOffset;
        uint32_t mNormalized;
    };

    class NEAPI VertexAttribute
    {
        public:
            VertexAttribute(const uint32_t bufferSource,
                            const AttributeSemantic semantic,
                            const AttributeType type,
                            const uint32_t count,
                            const uint32_t stride,
                            const size_t offset,
                            const bool normalized=false);

            uint32_t getSource() const;

            AttributeSemantic getSemantic() const;

            AttributeType getType() const;

            uint32_t getCount() const;

            uint32_t getSize() const;

            GLDataType getGLDataType() const;

            uint32_t getGLDataCount() const;

            uint32_t getAttributeSize() const;

            uint32_t getStride() const;

            bool isInterleaved() const;

            size_t getOffset() const;

            void* getOffsetPointer() const;

            bool isNormalized() const;

            ~VertexAttribute();

        private:
            VertexAttribute();

            VertexAttribute(const VertexAttribute &);

            VertexAttribute& operator = (const VertexAttribute &);

        public:
            static PrimitiveType GetPrimitiveType(const std::string &str);

            static GLDataType GetGLDataType(const AttributeType type);

            static uint32_t GetGLDataCount(const AttributeType type);

            static uint32_t GetAttributeSize(const AttributeType type);

            static AttributeSemantic GetAttributeSemantic(const std::string &str);

            static AttributeType GetAttributeType(const std::string &str);

            static AttributeType GetFloatAttributeType(const uint32_t size);

            static AttributeType GetDoubleAttributeType(const uint32_t size);

            static AttributeType GetColorAttributeType(const uint32_t size);

            static AttributeType GetIntAttributeType(const uint32_t size, const uint32_t count);

            static AttributeType GetIndexAttributeType(const uint32_t count);

        private:
            uint32_t mSource;
            AttributeSemantic mSemantic;
            AttributeType mType;
            uint32_t mCount;
            uint32_t mStride;
            size_t mOffset;
            bool mNormalized;
    };

    typedef SharedPtr<VertexAttribute> VertexAttributePtr;

    typedef std::map<AttributeSemantic, VertexAttributePtr> VertexAttributeMap;
    typedef VertexAttributeMap::iterator VertexAttributeMapIterator;
    typedef VertexAttributeMap::const_iterator VertexAttributeMapConstIterator;

    typedef std::list<VertexAttributePtr> VertexAttributeList;
    typedef VertexAttributeList::iterator VertexAttributeListIterator;
    typedef VertexAttributeList::const_iterator VertexAttributeListConstIterator;
}

#endif
